{extend name="common/base" }

{block name="style"}
<style type="text/css">
	#selectAll {
		color: #3bb4f2;
		cursor: pointer;
	}
</style>
{/block}

{block name="content"}
<div class="am-g">
	<div class="am-u-sm-12">
		<form class="am-form ajax-form" method="post" action="{:module_url('add')}">
		
			{$widget->form('text', ['title' => '分组名称', 'name' => 'group_name', 'value' => ''])}

			{$widget->form('checkbox', ['title' => '选择权限 <span id="selectAll">[全选]</span>', 'name' => 'videos[]', 'list' => $videoList])}

			{$widget->form('text', ['title' => '分组排序', 'name' => 'sort', 'value' => 0])}
			
			{$widget->form('submit', ['title' => '用户操作'])}

		</form>
	</div>
</div>
{/block}

{block name="script"}
<script type="text/javascript">
	$(function(){
		var selectAll = false;
		$('#selectAll').on('click', function(){
			if(selectAll){
				$("input[name='videos[]']:checkbox").each(function() {
					$(this).prop("checked", !$(this).prop("checked"));
				});
				$(this).text('全选');
				selectAll = false;
			}else{
				$("input[name='videos[]']:checkbox").prop("checked", true);
				$(this).text('反选');
				selectAll = true;
			}
		});
	});
</script>
{/block}